/*
 * Copyright Radosław Smogura, 2012. All rights reserved.
 *
 * The content of this file is confidential and it is intelectual property
 * of copyright owners.
 * 
 *
 * $URL: http://reprap-ide.googlecode.com/svn/trunk/RepRapIDE/RepRapProject/src/main/java/eu/softper/reprap/generator/SceneTriangle.java $
 * $Id: SceneTriangle.java 3 2012-11-19 10:58:30Z mail@smogura.eu $
 * $Revision: 3 $
 */
package eu.softper.reprap.generator;

import java.math.BigDecimal;
import java.util.Comparator;

/**
 *
 * @author Radosław Smogura
 */
public class SceneTriangle<T extends Number & Comparable<T>> {
    private final DecimalVertex<T>[] vertices;
    private final DecimalVertex<T> normal;
    
    public SceneTriangle(DecimalVertex<T> v1, DecimalVertex<T> v2, DecimalVertex<T> v3, DecimalVertex<T> normal) {
        vertices = new DecimalVertex[] {v1, v2, v3};
        this.normal = normal;
    }
    
    public DecimalVertex<T> getV1() {
        return vertices[0];
    }

    public DecimalVertex<T> getV2() {
        return vertices[1];
    }

    public DecimalVertex<T> getV3() {
        return vertices[2];
    }

    public DecimalVertex<T>[] getVertices() {
        return vertices;
    }

    public DecimalVertex<T> getNormal() {
        return normal;
    }
    
    public static class LowerHeightComparator<T extends Number & Comparable<T>> implements Comparator<SceneTriangle<T>> {
        @Override
        public int compare(SceneTriangle<T> o1, SceneTriangle<T> o2) {
            /* Be scene traingle first vertex has lowest zIndex value. */
            return o1.getV1().getZ().compareTo(o2.getV1().getZ());
        }
    
    }

    @Override
    public String toString() {
        return "" + vertices[0].toString() + ", " + vertices[1].toString() + ", " + vertices[2].toString();
    }
}
